(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/number/NumberShow.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '21f6f4EGJFI/6cxrGqruSI1', 'NumberShow', __filename);
// Script/number/NumberShow.ts

Object.defineProperty(exports, "__esModule", { value: true });
var Constant_1 = require("../constant/Constant");
var startGame_1 = require("../gameSwitch/startGame");
// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NumberShow = /** @class */ (function (_super) {
    __extends(NumberShow, _super);
    function NumberShow() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.one = null;
        _this.two = null;
        _this.three = null;
        _this.four = null;
        _this.num_0 = null;
        _this.num_1 = null;
        _this.num_2 = null;
        _this.num_3 = null;
        _this.num_4 = null;
        _this.num_5 = null;
        _this.num_6 = null;
        _this.num_7 = null;
        _this.num_8 = null;
        _this.num_9 = null;
        _this.eventSys = null;
        return _this;
        // update (dt) {}
    }
    NumberShow.prototype.start = function () {
        this.showNumber(Constant_1.Constant.PLAYER_SCORE);
    };
    /**
     * 改变积分器显示
     * @param score
     */
    NumberShow.prototype.showNumber = function (score) {
        var t = this;
        t.changeGameSpeedByScore(score);
        score = score > 9999 ? 9999 : score;
        var num = score + "";
        t.resetAllSprite();
        var numArry = num.split("");
        for (var i = 0; i < numArry.length; i++) {
            if (t.one.spriteFrame == null) {
                t.one.spriteFrame = t.getSpriteFrameFormNum(parseInt(numArry[i]));
                continue;
            }
            if (t.two.spriteFrame == null) {
                t.two.spriteFrame = t.getSpriteFrameFormNum(parseInt(numArry[i]));
                continue;
            }
            if (t.three.spriteFrame == null) {
                t.three.spriteFrame = t.getSpriteFrameFormNum(parseInt(numArry[i]));
                continue;
            }
            if (t.four.spriteFrame == null) {
                t.four.spriteFrame = t.getSpriteFrameFormNum(parseInt(numArry[i]));
                continue;
            }
        }
        ;
    };
    /**
     * 由分数改变游戏速度
     * @param score
     */
    NumberShow.prototype.changeGameSpeedByScore = function (score) {
        var speedRate = (score / 4) + 20;
        this.eventSys.getComponent(startGame_1.default).changeSpeed(speedRate);
    };
    /**
     * 通过数字获得对应的数字图
     * @param num
     */
    NumberShow.prototype.getSpriteFrameFormNum = function (num) {
        var t = this;
        switch (num) {
            case 0: return t.num_0;
            case 1: return t.num_1;
            case 2: return t.num_2;
            case 3: return t.num_3;
            case 4: return t.num_4;
            case 5: return t.num_5;
            case 6: return t.num_6;
            case 7: return t.num_7;
            case 8: return t.num_8;
            case 9: return t.num_9;
            default: return null;
        }
    };
    NumberShow.prototype.resetAllSprite = function () {
        this.one.spriteFrame = null;
        this.two.spriteFrame = null;
        this.three.spriteFrame = null;
        this.four.spriteFrame = null;
    };
    __decorate([
        property(cc.Sprite)
    ], NumberShow.prototype, "one", void 0);
    __decorate([
        property(cc.Sprite)
    ], NumberShow.prototype, "two", void 0);
    __decorate([
        property(cc.Sprite)
    ], NumberShow.prototype, "three", void 0);
    __decorate([
        property(cc.Sprite)
    ], NumberShow.prototype, "four", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_0", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_1", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_2", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_3", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_4", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_5", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_6", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_7", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_8", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], NumberShow.prototype, "num_9", void 0);
    __decorate([
        property(cc.Node)
    ], NumberShow.prototype, "eventSys", void 0);
    NumberShow = __decorate([
        ccclass
    ], NumberShow);
    return NumberShow;
}(cc.Component));
exports.default = NumberShow;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=NumberShow.js.map
        